﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            Class1 c1 = new Class1("无", 1, 18);
            Class1 c2 = new Class1("我", 2, 19);
            Class1 c3 = new Class1("之", 3, 20);
            Class1 c4 = new Class1("镜", 4, 30);

            ArrayList arrayList = new ArrayList();
            Console.WriteLine("请选择：1、添加学生信息。2、查询学生信息，3、删除学生信息  4、退出");
            int a = int.Parse(Console.ReadLine());
            switch (a)
            {   case 1:
                    
                    Console.WriteLine("请输入名字");
                    string name = Console.ReadLine();
                    Console.WriteLine("请输入学号");
                    int num = int.Parse(Console.ReadLine());
                    Console.WriteLine("请输入年龄");
                    int age = int.Parse(Console.ReadLine());
                    Class1 class1 = new Class1(name,num, age);



                    break;
                case 2:
                    Console.WriteLine("1、查询所有（按学号排序）2、按学号查询（查没有，则打印查无此学生）");
                    int b = int.Parse(Console.ReadLine());
                    switch (b)
                    {
                        case 1:
                            arrayList.Sort();

                            break;
                        case 2:
                            Console.WriteLine("请输入学号");
                            Class1 class11 = new Class1();
                            int num10 = int.Parse(Console.ReadLine());
                            class11.Num = num10;
                            bool flay = arrayList.Contains(class11.Num);
                            Console.WriteLine(flay);
                            if (flay ==false)
                            {
                                Console.WriteLine("查无此学生");

                            }
                            else
                            {
                                Console.WriteLine("存在");

                            }
                            break;
                        default:
                            Console.WriteLine("选错了");
                            break;
                    }
                    break;
                case 3:

                    ht.Remove(c1.Name);//是传key
                    Console.WriteLine("======删除后======");
                    foreach (var s in ht.Values)
                    {
                        Console.WriteLine(s);
                    }
                    break;
                case 4:
                    Environment.Exit(0);
                    break;
                default:
                    break;
            }
        }
    }
}
